package com.example.peibei.ui.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dingtao.common.bean.Order;
import com.dingtao.common.bean.RecommendMember;
import com.dingtao.common.util.GlideUtils;
import com.example.peibei.R;

import java.util.List;

public class MoreRecommendListAdapter extends BaseQuickAdapter<RecommendMember.RecordsDTO, BaseViewHolder> {

    public MoreRecommendListAdapter(@Nullable List<RecommendMember.RecordsDTO> data) {
        super(R.layout.item_order_list_two, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RecommendMember.RecordsDTO item) {
        if (item.isVip()){
            helper.setGone(R.id.iv_vip,false);
        }else {
            helper.setGone(R.id.iv_vip,true);
        }
        if ("0".equals(item.getUnit())){
            helper.setText(R.id.tv_unit,"/小时");
        }else if ("1".equals(item.getUnit())){
            helper.setText(R.id.tv_unit,"/天");
        }else if("-1".equals(item.getUnit())){
            helper.setText(R.id.tv_unit,"￥一口价");
        }
        ImageView head = helper.getView(R.id.iv_head);
        GlideUtils.loadImg(getContext(), item.getImgUrl(), 20, head);
        helper.setText(R.id.tv_name, item.getNickname()).setText(R.id.tv_address, item.getArea()).setText(R.id.tv_dec, item.getOtherDesc()).setText(R.id.tv_cate, item.getCategory())
                .setText(R.id.tv_online, item.getOnline());
        if (!TextUtils.isEmpty(item.getPrice())) {
            if (item.getPrice().contains(".")) {
                String[] split = item.getPrice().split("\\.");
                helper.setText(R.id.tv_price, split[0]);
            } else {
                helper.setText(R.id.tv_price, item.getPrice());
            }
        }
    }
}
